package com.FOD.entities;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.FOD.clases.R;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.widget.ArrayAdapter;

/**
 * Modelo para guardar temporalmente un usuario
 * @author rafa
 *
 */
public class User implements Parcelable{
	private int id;
	private String nickname;
	private String password;
	private String name;
	private String mail;
	private int type;
	private int age;
	private int sex;
	private String dependecy;
	private String sport;
	private long phone;
	private Date createDate;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getDependecy() {
		return dependecy;
	}

	public void setDependecy(String dependecy) {
		this.dependecy = dependecy;
	}

	public String getSport() {
		return sport;
	}

	public void setSport(String sport) {
		this.sport = sport;
	}

	public long getPhone() {
		return phone;
	}

	public void setPhone(long phone) {
		this.phone = phone;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}
	
	public int getConverterSexToInt(String sex, Context rootView){
		ArrayAdapter<CharSequence> adapter_sexType = ArrayAdapter.createFromResource(rootView,R.array.sex_types_spinner, android.R.layout.simple_spinner_item);
		return adapter_sexType.getPosition(sex);
	}
	
	public String getConverterSexToString(int sex, Context rootView){
		ArrayAdapter<CharSequence> adapter_sexType = ArrayAdapter.createFromResource(rootView,R.array.sex_types_spinner, android.R.layout.simple_spinner_item);
		return adapter_sexType.getItem(sex).toString();
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel parceUser, int arg1) {
		SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

		parceUser.writeInt(id);
		parceUser.writeString(nickname);
		parceUser.writeString(password);
		parceUser.writeString(name);
		parceUser.writeString(mail);
		parceUser.writeString(nickname);
		parceUser.writeInt(type);
		parceUser.writeInt(age);
		parceUser.writeInt(sex);
		parceUser.writeString(dependecy);
		parceUser.writeString(sport);
		parceUser.writeLong(phone);
		parceUser.writeString(df.format(createDate));

	}

}
